Skip to content

Pogodaeva_homework#3

Open
pogodaevala wants to merge 39 commits intoDafeCpp:mainfrom
pogodaevala:main
Open

Pogodaeva_homework#3
pogodaevala wants to merge 39 commits intoDafeCpp:mainfrom
pogodaevala:main

Conversation

@pogodaevala
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread task_03/src/days_before_hot.cpp Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 15 out of 27. Check the log or trigger a new build to see more.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_05/src/quick_sort.cpp Outdated
@@ -0,0 +1,44 @@
#include "quick_sort.hpp"

std::vector<double> Smaller(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::vector<double> Smaller(double elem, std::vector<double> input) {
std::vector<double> Smaller(double elem, const std::vector<double>&const e elem, std::vector&<double> input) {

Comment thread task_05/src/quick_sort.cpp Outdated
return smaller;
}

std::vector<double> Bigger(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::vector<double> Bigger(double elem, std::vector<double> input) {
std::vector<double> Bigger(double elem, const std::vector<double>& input) {

task_05/src/quick_sort.hpp:4:

- std::vector<double> Bigger(double elem, std::vector<double> input);
+ std::vector<double> Bigger(double elem, const std::vector<double>& input);

Comment thread task_05/src/quick_sort.cpp Outdated
return bigger;
}

std::vector<double> Eq(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::vector<double> Eq(double elem, std::vector<double> input) {
std::vector<double> Eq(double elem, const std::vector<double>& input) {

task_05/src/quick_sort.hpp:6:

- std::vector<double> Eq(double elem, std::vector<double> input);
+ std::vector<double> Eq(double elem, const std::vector<double>& input);

Comment thread task_07/src/avl_tree.hpp Outdated
Node* right_child = nullptr;
int height = 1;
Node(int key, int data) {
this->key = key;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'key' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

task_07/src/avl_tree.hpp:27:

-     Node(int key, int data) {
-       this->key = key;
+     Node(int key, int data) : key(key) {
+       

Comment thread task_07/src/avl_tree.hpp Outdated
int height = 1;
Node(int key, int data) {
this->key = key;
this->data = data;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'data' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

task_07/src/avl_tree.hpp:27:

-     Node(int key, int data) {
+     Node(int key, int data), data(data) {
Suggested change
this->data = data;

@pogodaevala pogodaevala changed the title task_03 and a little bit task_02 Pogodaeva_homework May 3, 2025
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread lib/src/util.cpp Outdated
@@ -1 +1,31 @@
#include "util.hpp"

std::vector<double> Smaller(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::vector<double> Smaller(double elem, std::vector<double> input) {
std::vector<double> Smaller(double elem, const std::vector<double>&const d::vector<double> i&nput);

Comment thread lib/src/util.cpp Outdated
return smaller;
}

std::vector<double> Bigger(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

lib/src/util.hpp:4:

- std::vector<double> Bigger(double elem, std::vector<double> input);
+ std::vector<double> Bigger(double elem, const std::vector<double>& input);
Suggested change
std::vector<double> Bigger(double elem, std::vector<double> input) {
std::vector<double> Bigger(double elem, const std::vector<double>& input) {

Comment thread lib/src/util.cpp Outdated
return bigger;
}

std::vector<double> Eq(double elem, std::vector<double> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

lib/src/util.hpp:6:

- std::vector<double> Eq(double elem, std::vector<double> input);
+ std::vector<double> Eq(double elem, const std::vector<double>& input);
Suggested change
std::vector<double> Eq(double elem, std::vector<double> input) {
std::vector<double> Eq(double elem, const std::vector<double>& input) {

@DafeCpp DafeCpp deleted a comment from github-actions Bot May 3, 2025
Comment thread task_02/src/stack.hpp Outdated

template <typename T>
requires(std::totally_ordered<T>)
T MinStack<T>::GetMin() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай сделаем метод константным)

Comment thread task_03/src/days_before_hot.hpp Outdated
#include <stack>
#include <vector>

struct TemperatureWithDayIndex {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай структурку внутрь cpp переместим, это реализация её лучше не светить

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 15 out of 19. Check the log or trigger a new build to see more.

Comment thread task_02/src/stack.hpp
};

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'T' does not refer to a value [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                                ^
Additional context

task_02/src/stack.hpp:33: declared here

template <typename T>
                   ^

Comment thread task_02/src/stack.hpp
};

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: a type specifier is required for all declarations [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
  ^

Comment thread task_02/src/stack.hpp
};

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: expected ';' after top level declarator [clang-diagnostic-error]

Suggested change
requires(std::totally_ordered<T>)
requires(std::totally_ordered<T>);

Comment thread task_02/src/stack.hpp
};

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: expected expression [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                                  ^

Comment thread task_02/src/stack.hpp
};

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no member named 'totally_ordered' in namespace 'std' [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                ^

Comment thread task_02/src/stack.hpp

private:
std::vector<int> data_;
Node<T>* head = nullptr;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'T' [clang-diagnostic-error]

  Node<T>* head = nullptr;
       ^

Comment thread task_02/src/stack.hpp
private:
std::vector<int> data_;
Node<T>* head = nullptr;
Node<T>* head_min = nullptr;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'T' [clang-diagnostic-error]

  Node<T>* head_min = nullptr;
       ^

Comment thread task_02/src/stack.hpp
}

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'T' does not refer to a value [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                                ^
Additional context

task_02/src/stack.hpp:84: declared here

template <typename T>
                   ^

Comment thread task_02/src/stack.hpp
}

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: a type specifier is required for all declarations [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
  ^

Comment thread task_02/src/stack.hpp
}

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: expected ';' after top level declarator [clang-diagnostic-error]

Suggested change
requires(std::totally_ordered<T>)
requires(std::totally_ordered<T>);

@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
Comment thread task_07/src/avl_tree.hpp

public:
friend std::ostream& operator<<(std::ostream& os, const AvlTree& tree);
class Iterator {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавь тестов для итератора

@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
Comment thread task_08/src/hash_table.cpp Outdated
@@ -0,0 +1,93 @@
#include "hash_table.hpp"

int HashTable::SecondHashFunc(std::string key) { return 1; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cons std::string&

@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
@DafeCpp DafeCpp deleted a comment from github-actions Bot May 10, 2025
Comment thread task_08/src/hash_table.cpp Outdated
array[index].value = new_value;
array[index].condition = Condition::Full;
full_elements += 1;
if (full_elements > array.size() / 2) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай в начале функции проверим, код будет проще

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_02/src/stack.hpp
}

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: expected expression [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                                  ^

Comment thread task_02/src/stack.hpp
}

template <typename T>
requires(std::totally_ordered<T>)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no member named 'totally_ordered' in namespace 'std' [clang-diagnostic-error]

  requires(std::totally_ordered<T>)
                ^

Comment thread task_02/src/stack.hpp

template <typename T>
requires(std::totally_ordered<T>)
void MinStack<T>::Push(T value) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: expected ';' after top level declarator [clang-diagnostic-error]

Suggested change
void MinStack<T>::Push(T value) {
void MinStack;<T>::Push(T value) {

Comment thread task_02/src/stack.hpp

template <typename T>
requires(std::totally_ordered<T>)
void MinStack<T>::Push(T value) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable has incomplete type 'void' [clang-diagnostic-error]

void MinStack<T>::Push(T value) {
     ^

Comment thread task_07/src/avl_tree.cpp
}

AvlTree::Node* AvlTree::LeftRightImbalance(Node* old_par) {
Node* new_par = RightRightImbalance(old_par->left_child);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Value stored to 'new_par' during its initialization is never read [clang-analyzer-deadcode.DeadStores]

ance(Node* old_par) {
                              ^
Additional context

task_07/src/avl_tree.cpp:198: Value stored to 'new_par' during its initialization is never read

ance(Node* old_par) {
                              ^

Comment thread task_07/src/avl_tree.cpp
}

AvlTree::Node* AvlTree::RightLeftImbalance(Node* old_par) {
Node* new_par = LeftLeftImbalance(old_par->right_child);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Value stored to 'new_par' during its initialization is never read [clang-analyzer-deadcode.DeadStores]

ance(Node* old_par) {
                              ^
Additional context

task_07/src/avl_tree.cpp:204: Value stored to 'new_par' during its initialization is never read

ance(Node* old_par) {
                              ^

Comment thread task_07/src/avl_tree.hpp

private:
Node* current_node;
const AvlTree& tree;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'tree' of type 'const AvlTree &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

    const AvlTree& tree;
                   ^

@@ -0,0 +1,95 @@
#include "hash_table.hpp"

int HashTable::SecondHashFunc(const std::string& key) { return 1; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'key' is unused [misc-unused-parameters]

Suggested change
int HashTable::SecondHashFunc(const std::string& key) { return 1; }
int HashTable::SecondHashFunc(const std::string& /*key*/) { return 1; }

Comment thread task_08/src/hash_table.cpp Outdated
array = vec;
}

HashTable::HashTable(std::vector<std::pair<std::string, int>> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'input' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

task_08/src/hash_table.hpp:14:

-   HashTable(std::vector<std::pair<std::string, int>> input);
+   HashTable(const std::vector<std::pair<std::string, int>>& input);
Suggested change
HashTable::HashTable(std::vector<std::pair<std::string, int>> input) {
HashTable::HashTable(const std::vector<std::pair<std::string, int>>& input) {

Comment thread task_08/src/hash_table.cpp Outdated
HashTable::HashTable(std::vector<std::pair<std::string, int>> input) {
std::vector<Element> vec(input.size() * 3);
array = vec;
for (auto elem : input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]

Suggested change
for (auto elem : input) {
for (const auto& elem : input) {

Comment thread task_09/src/task.cpp Outdated
}
bool is_found{false};
for (int j{0}; j < matrix[0].size(); ++j) {
if (prefikses_from_bools[r][j] - prefikses_from_bools[l][j] ==
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefixes

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_02/src/stack.hpp
}
void Push(T value);
T Pop();
T const GetMin();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'T' [clang-diagnostic-error]

  T const GetMin();
  ^

Comment thread task_08/src/hash_table.cpp Outdated
array = vec;
}

HashTable::HashTable(const std::vector<std::pair<std::string, int>> input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the const qualified parameter 'input' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]

task_08/src/hash_table.hpp:14:

-   HashTable(const std::vector<std::pair<std::string, int>> input);
+   HashTable(const std::vector<std::pair<std::string, int>>& input);
Suggested change
HashTable::HashTable(const std::vector<std::pair<std::string, int>> input) {
HashTable::HashTable(const std::vector<std::pair<std::string, int>>& input) {

Comment thread task_08/src/hash_table.cpp Outdated
HashTable::HashTable(const std::vector<std::pair<std::string, int>> input) {
std::vector<Element> vec(input.size() * 3);
array = vec;
for (const auto elem : input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the loop variable's type is not a reference type; this creates a copy in each iteration; consider making this a reference [performance-for-range-copy]

Suggested change
for (const auto elem : input) {
for (const auto& elem : input) {

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_05/src/quick_sort.cpp Outdated
#include <algorithm>
#include <vector>

void QuickSortInplace(std::vector<double>& arr, int left, int right) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'QuickSortInplace' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]

Suggested change
void QuickSortInplace(std::vector<double>& arr, int left, int right) {
static void QuickSortInplace(std::vector<double>& arr, int left, int right) {

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

#include <algorithm>
#include <vector>

static void QuickSortInplace(std::vector<double>& arr, int left, int right) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'QuickSortInplace' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]

static void QuickSortInplace(std::vector<double>& arr, int left, int right) {
            ^

Comment thread task_04/src/fish_days.hpp
@@ -0,0 +1,3 @@
#include <vector>
std::vector<int> calculate_fish_days(int N, int K,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CalculateFishDays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants